<?php

class HttpUtil
{
	
	  public static function getGetValue ($field)
    {
        return $_GET[$field];
    }
    
    public static function getPostValue ($field)
    {
        return $_POST[$field];
    }
    public static function getPostString ($field)
    {
        $value = $_POST[$field];
        if (isset($value)) {
            $value = trim($value);
            return $value;
        } else {
            return '';
        }
    }
    public static function getGetString ($field)
    {
        $value = $_GET[$field];
        if (isset($value)) {
            $value = trim($value);
            return $value;
        } else {
            return '';
        }
    }
    public static function getSessionString ($field, $node = "")
    {
        if (! empty($node)) {
            $value = $_SESSION[$node][$field];
        } else {
            $value = $_SESSION[$field];
        }
        if (isset($value)) {
            $value = trim($value);
            return $value;
        } else {
            return '';
        }
    }
    public static function getFilesString ($node, $field)
    {
        $value = $_FILES[$node][$field];
        if (isset($value)) {
            $value = trim($value);
            return $value;
        } else {
            return '';
        }
    }
    public static function getResultString ($result)
    {
        if (isset($result)) {
            if (is_array($result)) {
                foreach ($result as $key => $value) {
                    if (is_array($value)) {
                        foreach ($value as $k => $val) {
                            $value[$k] = stripslashes($val);
                            $result[$key] = $value;
                        }
                    } else {
                        $result[$key] = stripslashes($value);
                    }
                }
            } else {
                $result = stripslashes($result);
            }
            return $result;
        } else {
            return "";
        }
    }
    public static function getSelectDateString ($date)
    {
        if (isset($date)) {
            $date = explode(" - ", $date);
            foreach ($date as $key => $value) {
                $date = explode("/", $value);
                $result[$key] = $date[2] . "-" . $date[0] . "-" . $date[1];
            }
            return $result;
        } else {
            return "";
        }
    }

    public static function baseUrl(){
        $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
        return $baseUrl;
    }

    public static function getUrl($controller,$action){
        return Zend_View_Helper_Url::url(array('controller' => $controller , 'action' => $action));
    }
    
    public function iReplaceAllUrlStr($str){
    	$str = str_ireplace("/","",$str);
    	$str = str_ireplace(" ","-",$str);
    	$str = str_ireplace("#","",$str);
    	$str = str_ireplace(".","",$str);
    	$str = str_ireplace("'","",$str);
    	$str = str_ireplace("?","",$str);
    	$str = str_ireplace("%","",$str);
    	$str = str_ireplace("\"","",$str);
    	return $str;
    }

}
?>